Macromedia Flex Article

Learning Flex Basics (Part 1): Creating Your First Flex Application


Robert Crooks

Robert Crooks

Macromedia Training

Table of Contents

  1. Introduction
  2. A Brief Overview of Macromedia Flex
  3. Building the Application
  4. Create the Application Object
  5. Add a Panel for the Application Layout
  6. Add a Label for the View Header
  7. Add an Array of Objects to Define the Coffee Blends
  8. Add a ComboBox to Display the Coffee Blends
  9. Add a Text Control to Display the Description
  10. Add a Button to Add a Coffee Blend to the Shopping Cart
  11. Add a List Control for the Shopping Cart
  12. Add a Script to Handle the Button Click Event
  13. Complete Code Listing for firstapp.mxml
  14. Where to Go From Here

In this tutorial you will learn the basic elements of Macromedia Flex applications through an overview and through building a simplified catalog and shopping cart in MXML. To do this you will create an application, add a layout container, add controls, create a simple data model that is bound to controls, and finally create event-handler functions in ActionScript.

This tutorial is the first part in a four-part series written by Robert Crooks of the Macromedia Customer Training group:

If you prefer, you can download the entire set of tutorials.

If you like what you see and want to get more experience with Flex, Macromedia Customer Training offers Fast Track to Macromedia Flex, a two-day onsite training course to jump-start Flex development in your organization. Now let's get started!

If you are new to writing XML languages, remember these basic rules:

  • Both tag and attribute names in MXML, as in all XML languages is case-sensitive
  • All values for attributes must be in single or double quotation marks
  • All tags must be closed. Tags that contain no nested tags or content can be closed with a simple slash rather than a full end tag:
<mx:Label text="Hello"></mx:Label>
or
<mx:Label text="Hello"/>

If you are new to ActionScript, you will probably find the syntax similar to languages you already know, such as JavaScript or Java. Remember these basic rules:

  • ActionScript is case-sensitive
  • Statements are terminated by a semi-colon (;)

What You Will Learn:

  1. Get a brief overview of Flex
  2. How to use the Application tag.
  3. How to use a Panel container.
  4. How to use a Label control.
  5. How to use a Text control.
  6. How to use Button controls.
  7. How to use a ComboBox control.
  8. How to create an array of objects.
  9. How to bind data to controls.
  10. How to create an ActionScript handler for a user event.

Requirements

To complete this tutorial you will need to install the following software and files:

Macromedia Flex

(Installed and running on any server and platform supported by Flex. Note that the Flex trial is available on CD from the Macromedia store for $8.99. To learn more about the Flex trial, please read the Flex Frequently Asked Questions.)

Dreamweaver MX 2004 or a text editor that you can use to write XML and ActionScript code (a basic text editor such as Notepad is adequate)

Solution files for this tutorial:

Prerequisite knowledge:



About the author

Robert Crooks is the Director of Curriculum Development for Macromedia. He has written several courses on creating internet applications including the beta version of Fast Track to Macromedia Flex.